import type { loginFormData, loginInfoResponseData, userInfoResponseData, Patient, patientListResponseData, sendFormData, sendFormResponseData, loginFormData1, patientResponseData, addPatientResponseData } from '@/types/user'
import { request } from '@/utils/request'

//项目用户相关的请求地址
enum API {
    LOGIN_PASSWORD_URL = "/login/password",
    LOGIN_CODE_URL = "login",
    CODE_URL = "/code",
    USER_INFO_URL = '/patient/myUser',
    PATIENT_LIST_URL = "/patient/mylist",
    PATIENT_ADD_URL = "/patient/add",
    PATIENT_EDIT_URL = "/patient/update",
    PATIENT_DELETE_URL = "/patient/del",
    DETAIL_URL = "/patient/info",

}
//密码登录
export const loginByPassword = (data: loginFormData) => request.post<any, loginInfoResponseData>(API.LOGIN_PASSWORD_URL, data)
//验证码登录
export const loginByCode = (data: loginFormData1) => request.post<any, loginInfoResponseData>(API.LOGIN_CODE_URL, data)
// 发送验证码
export const sendMobileCode = (data: sendFormData) => request.get<any, sendFormResponseData>(API.CODE_URL, { params: data })

//获取用户信息
export const getUserInfo = () => request.get<any, userInfoResponseData>(API.USER_INFO_URL)

// 获患者信息列表
export const getPatientList = () => request.get<any, patientResponseData>(API.PATIENT_LIST_URL)

// 添加患者信息
export const addPatient = (patient: Patient) => request.post<any, addPatientResponseData>(API.PATIENT_ADD_URL, patient)
// 编辑患者信息
export const editPatient = (patient: Patient) => request.put<any, any>(API.PATIENT_EDIT_URL, patient)
// 删除患者信息
export const delPatient = (id: string) => request.delete(`${API.PATIENT_DELETE_URL}/${id}`)

// 查询患者详情
export const getPatientDetail = (id: string | undefined) => request.get<any, patientListResponseData>(`${API.DETAIL_URL}/${id}`)

